<template>
  <div class="tab_bar_container">
    <div class="tab_bar_wrapper">
      <TabbarItem v-for="(item,index) in items"
      :key="index"
      :item="item"
      :selectIndex="selectIndex"
      :index="index"
      @changeIndex="changeIndex"/>
    </div>
  </div>
</template>

<script>
import TabbarItem from "../components/TabbarItem";
export default {
  components:{
    TabbarItem
  },
  props:{
    items:{
      type:Array,
      required: true,
      validator:function(value){
        return value.length<=6
      }
    }
  },
  data(){
    return{
      selectIndex:0
    }
  },
  methods:{
    changeIndex(index){
      this.selectIndex = index;
      var path = this.items[this.selectIndex].path
      this.$router.push(path)
    }
  }
}
</script>

<style scoped>
.tab_bar_container
{
  width: 100%;
  height: 64px;
  border: 1px solid red;
  position: fixed;
  bottom: 0px;
  left: 0px;
}
.tab_bar_wrapper
{
  width: 100%;
  height: 64px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}
</style>